package club.zbiao.modules.system.service;

import club.zbiao.modules.system.domain.Permission;
import club.zbiao.modules.system.service.dto.PermissionDTO;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

/**
 * @author jie
 * @date 2018-12-08
 */
@CacheConfig(cacheNames = "permission")
public interface PermissionService extends BaseService<PermissionDTO, Permission> {

    /**
     * permission tree
     *
     * @return
     */
    @Cacheable(key = "'tree'")
    Object getPermissionTree(List<Permission> permissions);

    /**
     * findByPid
     *
     * @param pid
     * @return
     */
    @Cacheable(key = "'pid:'+#p0")
    List<Permission> findByPid(long pid);

    /**
     * build Tree
     *
     * @param permissionDTOS
     * @return
     */
    @Cacheable(keyGenerator = "keyGenerator")
    Object buildTree(List<PermissionDTO> permissionDTOS);
}
